<table class="data">
    <thead>
        <tr>
            <th width="50px"><?php echo 'No'; ?></th>
            <th><?php echo 'Name'; ?></th>
            <th class="collect_date"><?php echo 'Collect Date'; ?></th>
            <th class="collector"><?php echo 'Collector'; ?></th>
            <th class="action">&nbsp;</th>
        </tr>
    </thead>
    <tbody>
        <?php if (empty($this->data)) : // ถ้าไม่มีข้อมูล ?>
        <tr>
            <td colspan="6"><div class="fail-flash">This warehouse doesn't have any location.</div></td>
        </tr>
        <? else : // ถ้ามีข้อมูล ?>
            <?php $i = 0; foreach($this->data as $location): ?>
                <?php
                $tableCell = array();
                $tableCell[] = ++$i;
                $tableCell[] = $html->tag('span', $location['Location']['name'], array('id' => "name$i"));
                $tableCell[] = $html->tag('span', $location['Location']['modified'], array('class' => 'lower'));
                $tableCell[] = $html->tag('span', $location['User']['name']);
                $tableCell[] = $my->confirmLink($html->image('icon/delete.png', array('title' => 'delete', 'alt' => 'delete')), "{$this->name}/delete_location/{$location['Location']['id']}", 'Do you want to delete \"' . $location['Location']['name'] . '\"?', 'divLocations', false);
                echo $html->tableCells($tableCell, array('class' => 'odd-cell'), array('class' => 'even-cell'));
                echo $ajax->editor("name$i", "/warehouses/location_inplace_editor/name/{$location['Location']['id']}");
                ?>
            <?php endforeach; ?>
        <?php endif; ?>
        <tr>
            <td>&nbsp;</td>
            <td colspan="5">
                    <?php echo $ajax->form(null, 'post', array('update'=>'divLocations', 'indicator' => 'indicator', 'url' => array('controller'=>'warehouses','action'=>'save_location'))); ?>
                    <?php echo $form->text('Location.name'); ?>
                    <?php echo $form->hidden('Location.warehouse_id', array('value' => $warehouse_id)); ?>
                <span class="toolbar" style="border: none; margin: 0px;">
                        <?php echo $this->element('toolbar', array('buttons' => array('save'))); ?>
                </span>
                    <?php echo $form->end(); ?>
            </td>
        </tr>
    </tbody>
</table>
<?php //debug($this->data); ?>